/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package py.com.peluq.model.entity;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Diego_M
 */
@Entity
@Table(name = "caja", catalog = "peludb", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Caja.findAll", query = "SELECT c FROM Caja c"),
    @NamedQuery(name = "Caja.findByCodCaj", query = "SELECT c FROM Caja c WHERE c.codCaj = :codCaj"),
    @NamedQuery(name = "Caja.findByDesCaj", query = "SELECT c FROM Caja c WHERE c.desCaj = :desCaj")})
public class Caja implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "cod_caj", nullable = false)
    private Integer codCaj;
    @Size(max = 20)
    @Column(name = "des_caj", length = 20)
    private String desCaj;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "codCaj")
    private Collection<AperCierre> aperCierreCollection;

    public Caja() {
    }

    public Caja(Integer codCaj) {
        this.codCaj = codCaj;
    }

    public Integer getCodCaj() {
        return codCaj;
    }

    public void setCodCaj(Integer codCaj) {
        this.codCaj = codCaj;
    }

    public String getDesCaj() {
        return desCaj;
    }

    public void setDesCaj(String desCaj) {
        this.desCaj = desCaj;
    }

    @XmlTransient
    public Collection<AperCierre> getAperCierreCollection() {
        return aperCierreCollection;
    }

    public void setAperCierreCollection(Collection<AperCierre> aperCierreCollection) {
        this.aperCierreCollection = aperCierreCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (codCaj != null ? codCaj.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Caja)) {
            return false;
        }
        Caja other = (Caja) object;
        if ((this.codCaj == null && other.codCaj != null) || (this.codCaj != null && !this.codCaj.equals(other.codCaj))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "py.com.peluq.model.entity.Caja[ codCaj=" + codCaj + " ]";
    }
    
}
